package youkeda;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class TcpClient {

    public static void main(String[] args) throws IOException {
        Socket socket=new Socket("127.0.0.1",8888);

        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("hello client".getBytes());

        //得到客户端传过来的信息
        InputStream inputStream = socket.getInputStream();
        byte[] bytes=new byte[1024];
        int length=inputStream.read(bytes);
        System.out.println(new String(bytes,0,length));

        outputStream.close();
    }


}
